package com.chencs.app.category.controller;

import com.alibaba.fastjson.JSON;
import com.chencs.app.category.service.AppCategoryService;
import com.chencs.vo.biz.category.CategoryModel;
import com.chencs.vo.biz.product.KeyModel;
import com.chencs.vo.net.request.CategoryRequest;
import com.chencs.vo.net.request.RequestBase;
import com.chencs.vo.net.response.CategoryResponse;
import com.chencs.vo.net.response.KeyResponse;
import framework.model.ResponseOptUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * Created by Administrator on 2017/10/9.
 */

@RestController
@RequestMapping("/app/category")
public class AppCategoryController {

    @Autowired
    private AppCategoryService appCategoryService;
    @RequestMapping(value = "/categoryList", method = RequestMethod.POST)
    public String categoryList(@RequestBody CategoryRequest request){
        String retStr = "";
        try {
            retStr = appCategoryService.categoryList(request);
        } catch (Exception e) {
            retStr = ResponseOptUtil.commonMsgError( ResponseOptUtil.RET_FAIL_MSG);
            e.printStackTrace();
        }
        return retStr;
    }



    @RequestMapping(value = "/getAllCategoryList", method = RequestMethod.POST, produces = "application/json; charset=UTF-8")
    public String getAllCategoryList(@RequestBody CategoryRequest request){
        String retStr = "";
        try {
            retStr = appCategoryService.getAllCategoryList(request);
        } catch (Exception e) {
            retStr = ResponseOptUtil.commonMsgError( ResponseOptUtil.RET_FAIL_MSG);
            e.printStackTrace();
        }
        return retStr;
    }



    @RequestMapping(value = "/getOtherCategoryList", method = RequestMethod.POST, produces = "application/json; charset=UTF-8")
    public String getOtherCategoryList(@RequestBody CategoryRequest request){
        String retStr = "";
        try {
            retStr = appCategoryService.getOtherCategoryList(request);
        } catch (Exception e) {
            retStr = ResponseOptUtil.commonMsgError( ResponseOptUtil.RET_FAIL_MSG);
            e.printStackTrace();
        }
        return retStr;
    }


    @RequestMapping(value = "/keyList", method = RequestMethod.POST, produces = "application/json; charset=UTF-8")
    public String getkeyList(@RequestBody RequestBase request){
        String retStr = "";
        try {
            retStr = appCategoryService.getKeyList(request);
        } catch (Exception e) {
            retStr = ResponseOptUtil.commonMsgError( ResponseOptUtil.RET_FAIL_MSG);
            e.printStackTrace();
        }
        return retStr;
    }


}
